import diff from './diff'
export default class Component {
  constructor (props) {
    this.props = props
  }
  setState (state) {
    this.state = Object.assign({}, this.state, state)
    // 获取最新要渲染的virtualDom
    let virtualDom = this.render()
    // 获取页面中旧的virtualDom
    let oldDom = this.getDom()
    let container = oldDom.parentNode
    diff(virtualDom, container, oldDom )
  }
  setDom (dom) {
    this._dom = dom
  }
  getDom () { 
    return this._dom
  }
  updateProps (props) {
    this.props = props
  }

  // 生命周期函数
  componentWillMount() {}
  componentDidMount() {}
  componentWillReceiveProps(nextProps) {}
  shouldComponentUpdate(nextProps, nextState) {
    return nextProps != this.props || nextState != this.state
  }
  componentWillUpdate(nextProps, nextState) {}
  componentDidUpdate(prevProps, preState) {}
  componentWillUnmount() {}
}

